import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { setName } from './store/stuSlice';
import { setName as setSchoolName} from './store/schoolSlice';


const App = () => {
    // const stu = useSelector(state => state.stu)
    // const school = useSelector(state => state.school)
    const {stu, school} = useSelector(state => state)

    const dispatch = useDispatch();

    const setNameHandler = () => {
        dispatch(setName('新名字654'))    
    }
    const setSchoolNameHandler = () => {
        dispatch(setSchoolName('北京大学')) 
    }
    return (
        <div>
            {stu.name}
            <br/>
            {stu.age}
            <br/>
            <button onClick={setNameHandler}>设置新名字</button>
            <br/>
            {school.name}
            <br/>
            <button onClick={setSchoolNameHandler}>设置学校新名字</button>
        </div>
    )
};

export default App;
